-
Notifications
You must be signed in to change notification settings - Fork 848
Fix race conditions in Regex.cc. #11399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c6713d5 to
976c730
Compare
These changes should prevent (low-frequency) crashes that are being seen in Yahoo Prod.
|
Should this be added to 10.0.x project as well for cherry-pick? |
Debatable. Any crashes would happen at shutdown, and seem infrequent (with limited testing in Yahoo Prod). |
|
This is where the segment violation is occurring in Yahoo Prod: trafficserver/src/tsutil/Regex.cc Line 114 in 5f52c37
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could RegexContext be automatic within the thread? i.e.
RegexContext* get_instance() {
thread_local RegexContext ctx;
return &ctx;
}
Why is the global vector of contexts necessary at all?
IIRC this was originally done because some Debug statements in destructors could come after the shutdown of the thread's regex context. But if we use Dbg in those locations, then this isn't a problem anymore?
|
Could also look at how Metrics storage lifetime outlasts the threads and see if this would work for _Data lifetime: https://github.com/apache/trafficserver/blob/master/src/tsutil/Metrics.cc#L34-L42 |
|
Yes, it would not be a logic error in creating automatic, function scope instances of RegexContext when one is needed. The issue is whether the performance hit is tolerable. On the other hand, this change involves multiple threads/cores hardware locking a variable in cache, which is also a potentially significant performance hit. |
Because of trafficserver/src/tsutil/DbgCtl.cc Line 161 in 0a53513
I guess I should look into changing DbgCtl:::_new_reference() so it doesn't call tag_activated() with its mutex locked. |
|
Closing this because I think #11416 is better. |
These changes should prevent (low-frequency) crashes that are being seen in Yahoo Prod.